package com.ljx.rabbit.mapper;

import com.ljx.rabbit.domain.po.Brand;
import com.ljx.rabbit.domain.po.Item;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ljx.rabbit.domain.po.Properties;
import com.ljx.rabbit.domain.vo.SkuVo;
import com.ljx.rabbit.domain.vo.SpecsVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 商品 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2025-01-21
 */
public interface ItemMapper extends BaseMapper<Item> {

    @Select("select * from item order by publish_time desc limit #{limit}")
    List<Item> getNewGoods(Integer limit);


    List<SkuVo> getSkuVos(Long id);

    List<SpecsVo> getSpecsVos(Long id);

    @Select("select * from item join brand b on item.brand_id = b.id where item.id=#{id}")
    Brand getBrand(Long id);

    @Select("select picture from picture where item_id=#{id}")
    List<String> getMainPictures(Long id);

    @Select("select * from properties where item_id=#{id}")
    List<Properties> getProperties(Long id);

    @Select("select item_id from skus where id=#{skuCode}")
    Long getItemIdBySkuId(Long skuId);

}
